package com.ylkj.bus.onoffline.monitor.rule.code;

import com.ylkj.bus.onoffline.monitor.rule.constant.RuleReportConstant;
import lombok.Getter;

/**
 * @Author: wengzx
 * @Date: 2025/4/23
 * @Desc:
 */
@Getter
public enum RuleReportProxyEnum {
    CPU_PROXY("1001", "cpu_overload"),
    CPU_PROXY_RECOVERY("1002", "cpu_overload"),
    MEMORY_PROXY("1003", "memory_overload"),
    MEMORY_PROXY_RECOVERY("1004", "memory_overload"),
    DISK_PROXY("1005", "disk_overload"),
    COVER_AND_CLOSE_THE_LID_PROXY("3013", "lid_opened_with_cover"),
    OPEN_THE_TOP_COVER_PROXY("3008", "lid_opened_with_cover"),
    END_CAP_CLOSING_PROXY("3014", "lid_opened_without_cover"),
    END_CAP_OPENING_PROXY("3009", "lid_opened_without_cover"),
    POWER_DOWN_PROXY("3007", "power_loss"),
    POWER_DOWN_PROXY_RECOVERY("3012", "power_loss"),
    HIGH_TEMPERATURE_PROXY("3003", "temperature"),
    LOW_TEMPERATURE_PROXY("3005", "temperature"),
    DEVICE_ONLINE_PROXY("online", "deviceOnline"),
    DEVICE_OFFLINE_PROXY("offline", "deviceOffline"),
    ;

    private final String event;

    private final String proxy;

    RuleReportProxyEnum(String event, String proxy) {
        this.event = event;
        this.proxy = proxy;
    }

    /**
     * 获取指标名称
     *
     * @param event 告警id
     * @return 指标名称
     */
    public static String getReportProxy(String event) {
        for (RuleReportProxyEnum value : values()) {
            if (value.getEvent().equalsIgnoreCase(event)) {
                return value.getProxy();
            }
        }
        return "";
    }

    //判断是否为恢复
    public static boolean isRecovery(String event) {
        return RuleReportConstant.RECOVERY_LIST.contains(event);
    }
}
